exports.homePage = (req, res) => {

    //获取参数信息
    var bodyParams = req.routeInfo.bodyParams;

    var uid = bodyParams.u_id;

    var resultData = {};

    //查询当天签到信息
    function searchPunchInfo(cb) {

        var year = common.getYMD()[0];
        var month = common.getYMD()[1];
        var day = common.getYMD()[2];

        R.SEND_HTTP(
            req,
            res,
            {
                url: CORE_APIConfig.coreAPI.punchSearch.Request_Api_Url + "/opr_is_delete/0/opr_uid/" + uid+"/opr_year/"+year+"/opr_month/"+month+"/opr_day/"+day,
                method: 'POST',
                data:{
                    fields:["opr_id"].join(",")
                }
            },
            function (data) {

                var punchRecord = data.result.data;
                var isPunch = false;
                if(punchRecord.length>0){
                    isPunch = true;
                }
                resultData.isPunch = isPunch;
                cb();

            }
        )
    }

    //查询消息列表
    function searchMessageNumber(cb) {

        R.SEND_HTTP(
            req,
            res,
            {
                url: CORE_APIConfig.coreAPI.noticeSearch.Request_Api_Url + "/on_is_read/0/on_is_delete/0/on_receiver_id/" + uid+"/skip/0/limit/3/sort_order/on_id-desc",
                method: 'POST',
                data:{
                    fields:["on_id","on_content","on_create_time"].join(",")
                }
            },
            function (data) {
                resultData.messagesList = data.result.data;
                cb();

            }
        )
    }

    //查询内部邮件
    function searchInternalMail(cb) {

        R.SEND_HTTP(
            req,
            res,
            {
                url: CORE_APIConfig.coreAPI.internalMailSearch.Request_Api_Url + "/oim_is_read/0/oim_is_delete/0/oim_type/1/oim_recipient/" + uid,
                method: 'POST',
                data:{
                    fields:["oim_id"].join(",")
                }
            },
            function (data) {
                resultData.interMailNum = data.result.data.length;
                cb();

            }
        )
    }

    //查询工作日志日志
    function searchJobLog(cb) {

        R.SEND_HTTP(
            req,
            res,
            {
                url: CORE_APIConfig.coreAPI.logSearch.Request_Api_Url + "/ojl_is_delete/0/ojl_uid/" + uid,
                method: 'POST',
                data:{
                    fields:["ojl_id"].join(",")
                }
            },
            function (data) {
                resultData.jobLogNum = data.result.data.length;
                cb();

            }
        )
    }

    //查询文档
    function searchDocument(cb) {

        R.SEND_HTTP(
            req,
            res,
            {
                url: CORE_APIConfig.coreAPI.documentUserSearch.Request_Api_Url + "/od_is_delete/0/od_uid/" + uid,
                method: 'POST',
                data:{
                    fields:["od_id"].join(",")
                }
            },
            function (data) {
                resultData.documentNum = data.result.data.length;
                cb();

            }
        )
    }

    //查询公告
    function searchAnnouncement(cb) {

        R.SEND_HTTP(
            req,
            res,
            {
                url: CORE_APIConfig.coreAPI.announcementUser.Request_Api_Url + "/oa_is_delete/0/oa_is_release/1/skip/0/limit/3/sort_order/oa_id-desc",
                method: 'POST',
                data:{
                    fields:["oa_id","oa_content","oa_create_time"].join(",")
                }
            },
            function (data) {
                resultData.announcement = data.result.data;
                cb();

            }
        )
    }

    //查询申请（带流程用户信息）
    function searchApplyProcess(cb) {

        R.SEND_HTTP(
            req,
            res,
            {
                url: CORE_APIConfig.coreAPI.applyProcessSearchInfo.Request_Api_Url + "/of_is_delete/0/oap_uid/"+uid+"/skip/0/limit/3/sort_order/of_id-desc",
                method: 'POST',
                data:{
                    fields:["of_id","of_name","oap_status"].join(",")
                }
            },
            function (data) {
                resultData.applyProcess = data.result.data;
                cb();

            }
        )
    }
    F.Serial([searchPunchInfo,searchMessageNumber,searchInternalMail,searchJobLog,searchDocument,searchAnnouncement,searchApplyProcess], () => {
        RES.successResponse(res,resultData);
    })
}